﻿///***************************************************************
/// 시  스  템 : Updms.Mny
/// 단위시스템 : MNY
/// 계      층 : Presentation Layer
/// 프로그램명 : Mny1012m
/// 파  일  명 : Mny1012m.aspx.cs
/// 설      명 : 보안카드관리
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2008-08-18 송시명   최초 작성
///***************************************************************
using System;
using System.Data;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using SMFramework.Data;
using SMFramework.Security;
using SMFramework.Utility;
using SMFramework.Web.UI.WebControls.Page;

using Base.AppFramework.Web.UI.CommandBar;
using Base.Dac;
using Updms.Mny.Exe;


namespace Updms.Mny
{
	public partial class Mny1012m : Updms.Common.BaseClass.PageBase
	{
		#region 전역영역

		//프로그램상수
		public static readonly string PID = "Mny1012m";
		public static readonly string gs_path_info = "/updms/Mny/" + PID + ".aspx";

		Global global = new Global();
		Crypto crypto = new Crypto();

		//페이징
		private int li_cur_page, li_row_count, li_st_page, li_ed_page;
		protected int li_page_size = 10;//GRID_PAGESIZE;// 한 페이지에 출력될 행의수

		//검색
		protected string kw1 = "";	//은행
		protected string kw2 = "";	//카드번호
		protected string kw3 = "";	//소유자

		//검색
		protected string kw_secu_1 = "";	// ls_no_list
		protected string kw_secu_2 = "";	// 보안카드번호

		//메뉴 선택값
		protected string gs_sm = "";

		// 페이지모드
		private string gs_page_mode = "";

		#endregion

		#region Page_Load, OnPageLoad

		protected void Page_Load(object sender, EventArgs e)
		{
			SetInit();
			if (!Page.IsPostBack)
			{
				// 최초 화면 로딩시 처리해야 할 부분
				OnPageLoad();
				SelectProcess();
			}
		}

		// OnPageLoad
		private void OnPageLoad()
		{
			SetLiterals(global.GetLabelInfoByPgmId(PID, LANG_SET));
			SetClientScript();
			SetBnkCd();
			SetSearchParameter();
		}

		#endregion

		#region InitializeComponent

		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			this.PreRender += new System.EventHandler(this.Page_PreRender);
		}

		#endregion

		#region SetClientScript

		private void SetClientScript()
		{
			//onKeyPress이벤트 (엔터검색)
			txt_search_card_num.Attributes.Add("onkeypress", "enterSearch(event)");
			txt_search_owner_nm.Attributes.Add("onkeypress", "enterSearch(event)");
			txt_secu_admin_pw.Attributes.Add("onkeypress", "enterSecuSearch(event)");
			txt_secu_search_no_01.Attributes.Add("onkeyup", "moveNextFocus('txt_secu_search_no_01','txt_secu_search_no_02', 2); enterSecuSearch(event)");
			txt_secu_search_no_02.Attributes.Add("onkeypress", "enterSecuSearch(event)");
		}

		#endregion

		#region SetInit, SetSearchParameter, SetSecuSearchParameter, ShowKeywordLabel

		//초기값설정
		private void SetInit()
		{
			lbl_search_flag.Text = "INIT";
			if (Request.QueryString["page"] == null || int.Parse(Request.QueryString["page"]) == 1)
			{
				li_cur_page = 1;
				li_st_page = 0;
				li_ed_page = li_page_size;
			}
			else
			{
				li_cur_page = int.Parse(Request.QueryString["page"]);
				li_st_page = (int.Parse(Request.QueryString["page"]) - 1) * li_page_size;
				li_ed_page = li_st_page + li_page_size;
			}

			gs_sm = (Request.QueryString["sm"] == null || Request.QueryString["sm"].Trim().Length != 7)
					? global.GetDirDepth(PID) : Request.QueryString["sm"].ToString();
		}

		//검색파라미터
		private void SetSearchParameter()
		{
			switch (lbl_search_flag.Text.Trim().ToUpper())
			{
				case "INIT":
					if (String.IsNullOrEmpty(Request.QueryString["kw1"]))	// url에 값이 없으면
					{
						kw1 = ddl_search_bnk_cd.SelectedValue;
					}
					else
					{
						kw1 = Server.UrlDecode(Request.QueryString["kw1"]);
						ddl_search_bnk_cd.SelectedValue = kw1;
					}
					
					if (String.IsNullOrEmpty(Request.QueryString["kw2"]))	// url에 값이 없으면
					{
						kw2 = txt_search_card_num.Text.Trim();
					}
					else
					{
						kw2 = Server.UrlDecode(Request.QueryString["kw2"]);
						txt_search_card_num.Text = kw2;
					}

					if (String.IsNullOrEmpty(Request.QueryString["kw3"]))	// url에 값이 없으면
					{
						kw3 = txt_search_owner_nm.Text.Trim();
					}
					else
					{
						kw3 = Server.UrlDecode(Request.QueryString["kw3"]);
						txt_search_owner_nm.Text = kw3;
					}
					break;
				case "SEARCH":
					kw1 = ddl_search_bnk_cd.SelectedValue;
					kw2 = txt_search_card_num.Text.Trim();
					kw3 = txt_search_owner_nm.Text.Trim();
					break;
			}
		}

		//보안번호검색파라미터
		private void SetSecuSearchParameter()
		{
			string ls_no_01 = (txt_secu_search_no_01.Text.Length == 1) ? "0" + txt_secu_search_no_01.Text : txt_secu_search_no_01.Text;
			string ls_no_02 = (txt_secu_search_no_02.Text.Length == 1) ? "0" + txt_secu_search_no_02.Text : txt_secu_search_no_02.Text;

			kw_secu_1 = "No_" + ls_no_01 + "," + "No_" + ls_no_02;
			kw_secu_2 = txt_card_num.Text.Trim();
		}

		//검색키워드
		private void ShowKeywordLabel()
		{
			string ls_kw1 = ConversionUtil.CompareReplace(ddl_search_bnk_cd.SelectedItem.Text, DDL_SELECT, "-");
			lbl_search_keyword.Text = ls_kw1 + " / " + kw2 + " / " + kw3;
		}

		#endregion

		#region 마스터 Method (SetBnkCd)

		//결재은행
		private void SetBnkCd()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();
			Mny1010m_NT _Mny1010m_NT = new Mny1010m_NT();

			lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);

			lo_ds.Merge(_Mny1010m_NT.GetUsingBnkCd(lo_dp));

			ddl_search_bnk_cd.Items.Clear();
			ddl_search_bnk_cd.DataSource = lo_ds;
			ddl_search_bnk_cd.DataMember = "UPDMS_MNY_BNK_ACCNT_INFO";
			ddl_search_bnk_cd.DataTextField = "Text";
			ddl_search_bnk_cd.DataValueField = "Value";
			ddl_search_bnk_cd.DataBind();
			ddl_search_bnk_cd.Items.Insert(0, new ListItem(DDL_SELECT, ""));

			ddl_bnk_cd.Items.Clear();
			ddl_bnk_cd.DataSource = lo_ds;
			ddl_bnk_cd.DataMember = "UPDMS_MNY_BNK_ACCNT_INFO";
			ddl_bnk_cd.DataTextField = "Text";
			ddl_bnk_cd.DataValueField = "Value";
			ddl_bnk_cd.DataBind();
		}

		#endregion

		#region 디테일 Method ()

		#endregion

		#region CRUD (SelectProcess, InsertProcess, UpdateProcess, DeleteProcess, SearchProcess)

		//조회
		private void SelectProcess()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();
			int li_page_count;

			//검색
			lo_dp.AddProperty("ls_bnk_cd", typeof(string), kw1);
			lo_dp.AddProperty("ls_card_num", typeof(string), kw2);
			lo_dp.AddProperty("ls_owner_nm", typeof(string), kw3);

			using (Mny1012m_NT _Mny1012m_NT = new Mny1012m_NT())
			{
				li_row_count = _Mny1012m_NT.GetSearchCount(lo_dp);	// 검색된 행수
				li_page_count = (int)((li_row_count - 1) / li_page_size) + 1;	// 총페이지수 계산

				//모두보기/페이징
				lo_dp.AddProperty("li_st_page", typeof(Int32), (cb_list_all.Checked) ? 0 : li_st_page);
				lo_dp.AddProperty("li_ed_page", typeof(Int32), (cb_list_all.Checked) ? li_row_count : li_ed_page);
				lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);
				lbl_page.Visible = !cb_list_all.Checked;

				lo_ds.Merge(_Mny1012m_NT.SelectProcess(lo_dp));
			}

			GridView1.DataSource = lo_ds;
			GridView1.DataBind();

			Pager pager = new Pager(this, ref lbl_page);
			pager.PageNavigation(
				li_cur_page,
				li_page_count,
				gs_path_info + "?sm=" + gs_sm + "&kw1=" + Server.UrlEncode(kw1) + "&kw2=" + Server.UrlEncode(kw2) + "&kw3=" + Server.UrlEncode(kw3) + "&page=");

			//결과출력(키워드, 검색행수)
			ShowKeywordLabel();
			lbl_result_count.Text = li_row_count.ToString("#,###,##0");
		}

		//저장
		private void InsertProcess()
		{
			using (Mny1012m_RT _Mny1012m_RT = new Mny1012m_RT())
			{
				int li_return = _Mny1012m_RT.InsertProcess(SetValue());
				string ls_msg_id = (li_return > 0) ? "MSG_INF_007" : "MSG_ERR_105";	//저장되었습니다:저장할 수 없습니다
				CallMsgBoxInAjax(ls_msg_id);

				SearchProcess();
			}
		}

		//수정
		private void UpdateProcess()
		{
			using (Mny1012m_RT _Mny1012m_RT = new Mny1012m_RT())
			{
				int li_return = _Mny1012m_RT.UpdateProcess(SetValue());
				string ls_msg_id = (li_return > 0) ? "MSG_INF_006" : "MSG_ERR_104";	//수정되었습니다:수정할 수 없습니다
				CallMsgBoxInAjax(ls_msg_id);

				SearchProcess();
			}
		}

		//삭제
		private void DeleteProcess(string ls_xml)
		{
			using (Mny1012m_RT _Mny1012m_RT = new Mny1012m_RT())
			{
				int li_return = _Mny1012m_RT.DeleteProcess(ls_xml);
				string ls_msg_id = (li_return > 0) ? "MSG_INF_004" : "MSG_ERR_103";	//삭제되었습니다:삭제할 수 없습니다
				CallMsgBoxInAjax(ls_msg_id);

				SearchProcess();
			}
		}

		//검색
		private void SearchProcess()
		{
			lbl_search_flag.Text = "SEARCH";
			SetSearchParameter();
			ClearValue();
			SelectProcess();
		}

		#endregion

		#region 보안번호 CRUD (SelectSecuProcess, SearchSecuProcess)

		//조회
		private void SelectSecuProcess()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			//검색
			lo_dp.AddProperty("ls_no_list", typeof(string), kw_secu_1);
			lo_dp.AddProperty("ls_card_num", typeof(string), kw_secu_2);
			lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);

			using (Mny1012m_NT _Mny1012m_NT = new Mny1012m_NT())
			{
				lo_ds.Merge(_Mny1012m_NT.GetSecuNum(lo_dp));

				if (!DataSetUtil.CheckRowCount(lo_ds, "UPDMS_MNY_BNK_SECU_CARD"))
				{
					CallMsgBoxInAjax("MSG_ERR_111");	// 등록된 내용이 없습니다
				}
				else
				{
					gs_page_mode = "U";
					string ls_no_01 = (txt_secu_search_no_01.Text.Length == 1) ? "0" + txt_secu_search_no_01.Text : txt_secu_search_no_01.Text;
					string ls_no_02 = (txt_secu_search_no_02.Text.Length == 1) ? "0" + txt_secu_search_no_02.Text : txt_secu_search_no_02.Text;
					lbl_secu_no_01.Text = "<span class=\"b color_darkred\">" + ls_no_01 + "</span> ";
					lbl_secu_no_02.Text = "<span class=\"b color_darkred\">" + ls_no_02 + "</span> ";
					
					txt_secu_card_info.Text = DataSetUtil.GetFldStr(lo_ds, "UPDMS_MNY_BNK_SECU_CARD", "Card_Info");
					
					string ls_rslt_01 = crypto.Decrypt(DataSetUtil.GetFldStr(lo_ds, "UPDMS_MNY_BNK_SECU_CARD", "No_" + ls_no_01));
					string ls_rslt_02 = crypto.Decrypt(DataSetUtil.GetFldStr(lo_ds, "UPDMS_MNY_BNK_SECU_CARD", "No_" + ls_no_02));

					//빈값 처리, 필요한 번호만 보여줌
					txt_secu_no_01.Text = ls_rslt_01.Length > 3 ? ls_rslt_01.Substring(0, 2) : "-";
					txt_secu_no_02.Text = ls_rslt_02.Length > 3 ? ls_rslt_02.Substring(2, 2) : "-";
				}
			}
		}

		//검색
		private void SearchSecuProcess()
		{
			SetSecuSearchParameter();
			ClearSecuValue();
			SelectSecuProcess();
		}

		#endregion

		#region SetValue, ClearValue, ClearSecuValue

		//SetValue
		private DataPack SetValue()
		{
			DataPack lo_dp = new DataPack();
			
			lo_dp.AddProperty("Seq",		typeof(string), lbl_pk.Text);
			lo_dp.AddProperty("Bnk_Cd",		typeof(string), ddl_bnk_cd.SelectedValue);
			lo_dp.AddProperty("Card_Num",	typeof(string), txt_card_num.Text);
			lo_dp.AddProperty("Owner_Nm",	typeof(string), txt_owner_nm.Text);
			lo_dp.AddProperty("No_01",		typeof(string), (txt_no_01.Text.Trim() == "") ? lbl_no_01.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_01.Text)));
			lo_dp.AddProperty("No_02",		typeof(string), (txt_no_02.Text.Trim() == "") ? lbl_no_02.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_02.Text)));
			lo_dp.AddProperty("No_03",		typeof(string), (txt_no_03.Text.Trim() == "") ? lbl_no_03.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_03.Text)));
			lo_dp.AddProperty("No_04",		typeof(string), (txt_no_04.Text.Trim() == "") ? lbl_no_04.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_04.Text)));
			lo_dp.AddProperty("No_05",		typeof(string), (txt_no_05.Text.Trim() == "") ? lbl_no_05.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_05.Text)));
			lo_dp.AddProperty("No_06",		typeof(string), (txt_no_06.Text.Trim() == "") ? lbl_no_06.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_06.Text)));
			lo_dp.AddProperty("No_07",		typeof(string), (txt_no_07.Text.Trim() == "") ? lbl_no_07.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_07.Text)));
			lo_dp.AddProperty("No_08",		typeof(string), (txt_no_08.Text.Trim() == "") ? lbl_no_08.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_08.Text)));
			lo_dp.AddProperty("No_09",		typeof(string), (txt_no_09.Text.Trim() == "") ? lbl_no_09.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_09.Text)));
			lo_dp.AddProperty("No_10",		typeof(string), (txt_no_10.Text.Trim() == "") ? lbl_no_10.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_10.Text)));			
			lo_dp.AddProperty("No_11",		typeof(string), (txt_no_11.Text.Trim() == "") ? lbl_no_11.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_11.Text)));
			lo_dp.AddProperty("No_12",		typeof(string), (txt_no_12.Text.Trim() == "") ? lbl_no_12.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_12.Text)));
			lo_dp.AddProperty("No_13",		typeof(string), (txt_no_13.Text.Trim() == "") ? lbl_no_13.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_13.Text)));
			lo_dp.AddProperty("No_14",		typeof(string), (txt_no_14.Text.Trim() == "") ? lbl_no_14.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_14.Text)));
			lo_dp.AddProperty("No_15",		typeof(string), (txt_no_15.Text.Trim() == "") ? lbl_no_15.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_15.Text)));
			lo_dp.AddProperty("No_16",		typeof(string), (txt_no_16.Text.Trim() == "") ? lbl_no_16.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_16.Text)));
			lo_dp.AddProperty("No_17",		typeof(string), (txt_no_17.Text.Trim() == "") ? lbl_no_17.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_17.Text)));
			lo_dp.AddProperty("No_18",		typeof(string), (txt_no_18.Text.Trim() == "") ? lbl_no_18.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_18.Text)));
			lo_dp.AddProperty("No_19",		typeof(string), (txt_no_19.Text.Trim() == "") ? lbl_no_19.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_19.Text)));
			lo_dp.AddProperty("No_20",		typeof(string), (txt_no_20.Text.Trim() == "") ? lbl_no_20.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_20.Text)));			
			lo_dp.AddProperty("No_21",		typeof(string), (txt_no_21.Text.Trim() == "") ? lbl_no_21.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_21.Text)));
			lo_dp.AddProperty("No_22",		typeof(string), (txt_no_22.Text.Trim() == "") ? lbl_no_22.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_22.Text)));
			lo_dp.AddProperty("No_23",		typeof(string), (txt_no_23.Text.Trim() == "") ? lbl_no_23.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_23.Text)));
			lo_dp.AddProperty("No_24",		typeof(string), (txt_no_24.Text.Trim() == "") ? lbl_no_24.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_24.Text)));
			lo_dp.AddProperty("No_25",		typeof(string), (txt_no_25.Text.Trim() == "") ? lbl_no_25.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_25.Text)));
			lo_dp.AddProperty("No_26",		typeof(string), (txt_no_26.Text.Trim() == "") ? lbl_no_26.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_26.Text)));
			lo_dp.AddProperty("No_27",		typeof(string), (txt_no_27.Text.Trim() == "") ? lbl_no_27.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_27.Text)));
			lo_dp.AddProperty("No_28",		typeof(string), (txt_no_28.Text.Trim() == "") ? lbl_no_28.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_28.Text)));
			lo_dp.AddProperty("No_29",		typeof(string), (txt_no_29.Text.Trim() == "") ? lbl_no_29.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_29.Text)));
			lo_dp.AddProperty("No_30",		typeof(string), (txt_no_30.Text.Trim() == "") ? lbl_no_30.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_30.Text)));			
			lo_dp.AddProperty("No_31",		typeof(string), (txt_no_31.Text.Trim() == "") ? lbl_no_31.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_31.Text)));
			lo_dp.AddProperty("No_32",		typeof(string), (txt_no_32.Text.Trim() == "") ? lbl_no_32.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_32.Text)));
			lo_dp.AddProperty("No_33",		typeof(string), (txt_no_33.Text.Trim() == "") ? lbl_no_33.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_33.Text)));
			lo_dp.AddProperty("No_34",		typeof(string), (txt_no_34.Text.Trim() == "") ? lbl_no_34.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_34.Text)));
			lo_dp.AddProperty("No_35",		typeof(string), (txt_no_35.Text.Trim() == "") ? lbl_no_35.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_35.Text)));
			lo_dp.AddProperty("No_36",		typeof(string), (txt_no_36.Text.Trim() == "") ? lbl_no_36.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_36.Text)));
			lo_dp.AddProperty("No_37",		typeof(string), (txt_no_37.Text.Trim() == "") ? lbl_no_37.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_37.Text)));
			lo_dp.AddProperty("No_38",		typeof(string), (txt_no_38.Text.Trim() == "") ? lbl_no_38.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_38.Text)));
			lo_dp.AddProperty("No_39",		typeof(string), (txt_no_39.Text.Trim() == "") ? lbl_no_39.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_39.Text)));
			lo_dp.AddProperty("No_40",		typeof(string), (txt_no_40.Text.Trim() == "") ? lbl_no_40.Text : crypto.Encrypt(ConversionUtil.DefaultValue(txt_no_40.Text)));
			lo_dp.AddProperty("Create_User",typeof(string), USER_ID);
			lo_dp.AddProperty("Create_Dt",	typeof(string), "");
			lo_dp.AddProperty("Update_User",typeof(string), USER_ID);
			lo_dp.AddProperty("Update_Dt",	typeof(string), "");
			
			return lo_dp;
		}

		//ClearValue
		private void ClearValue()
		{
			lbl_pk.Text = "";
			h_no.Value = "";
			ddl_bnk_cd.SelectedIndex = 0;
			txt_card_num.Text = "";
			txt_owner_nm.Text = "";
			txt_no_01.Text = "";
			txt_no_02.Text = "";
			txt_no_03.Text = "";
			txt_no_04.Text = "";
			txt_no_05.Text = "";
			txt_no_06.Text = "";
			txt_no_07.Text = "";
			txt_no_08.Text = "";
			txt_no_09.Text = "";
			txt_no_10.Text = "";
			txt_no_11.Text = "";
			txt_no_12.Text = "";
			txt_no_13.Text = "";
			txt_no_14.Text = "";
			txt_no_15.Text = "";
			txt_no_16.Text = "";
			txt_no_17.Text = "";
			txt_no_18.Text = "";
			txt_no_19.Text = "";
			txt_no_20.Text = "";
			txt_no_21.Text = "";
			txt_no_22.Text = "";
			txt_no_23.Text = "";
			txt_no_24.Text = "";
			txt_no_25.Text = "";
			txt_no_26.Text = "";
			txt_no_27.Text = "";
			txt_no_28.Text = "";
			txt_no_29.Text = "";
			txt_no_30.Text = "";
			txt_no_31.Text = "";
			txt_no_32.Text = "";
			txt_no_33.Text = "";
			txt_no_34.Text = "";
			txt_no_35.Text = "";
			txt_no_36.Text = "";
			txt_no_37.Text = "";
			txt_no_38.Text = "";
			txt_no_39.Text = "";
			txt_no_40.Text = "";
		}

		//ClearSecuValue
		private void ClearSecuValue()
		{
			txt_secu_admin_pw.Text = "";
			lbl_secu_no_01.Text = "";
			lbl_secu_no_02.Text = "";
			txt_secu_card_info.Text = "";
			txt_secu_no_01.Text = "";
			txt_secu_no_02.Text = "";
		}

		#endregion

		#region Page_PreRender, ChangePageMode

		// Page_PreRender
		private void Page_PreRender(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				using (AccessCheck access = new AccessCheck())
				{
					//접근권한 체크
					if (!access.CheckPgmAccessGrant(PID, USER_ID, ACCESS_LOG_INFO))
					{
						Response.Redirect(URL_NO_AUTHORITY_REDIRECT_BASE);	//사용자의 권한은 요청하신 페이지를 볼 수 없습니다
					}
					//사용권한별 버튼처리
					PagePreRender.SetVisibleCtrl(this, access.CheckPgmUsingGrant(USER_DIV, PID), access.GetVisibleCtrl(PID));
				}
			}
			ChangePageMode();
		}

		// ChangePageMode
		private void ChangePageMode()
		{
			switch (gs_page_mode)
			{
				case "":	//처음 페이지로드시
					td_list.Width = "100%";
					td_secu.Width = "0%";
					table_secu.Visible = false;
					break;
				case "R":	//검색버튼 클릭시
					td_list.Width = "100%";
					td_secu.Width = "0%";
					table_secu.Visible = false;
					break;
				case "U":	//그리드뷰 클릭시
					td_list.Width = "40%";
					td_secu.Width = "60%";
					table_secu.Visible = true;
					break;	
			}
			SetGridViewHeader(global.GetColumnListByPgmId(PID, LANG_SET));
		}

		#endregion	

		#region GridView이벤트

		//RowDataBound
		protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
		{
			if (e.Row.RowType == DataControlRowType.DataRow)
			{
				//마우스올렸을 때
				e.Row.Attributes.Add("onmouseover", "overBackground('GridView1', " + (e.Row.RowIndex + 1) + ")");
				e.Row.Attributes.Add("onmouseout", "outBackground('GridView1', 1)");

				//번호
				e.Row.Cells[1].Text = ((li_row_count - ((li_cur_page - 1) * li_page_size)) - e.Row.RowIndex).ToString();
			}
		}

		//RowCommand
		protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
		{
			GridView gv = (GridView)sender;
			GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer);

			LinkButton lbtn_rc = (LinkButton)GridView1.Rows[row.RowIndex].FindControl("lbtn_rc");

			//row.Cells[0].Text.ToString();//0.체크박스
			h_no.Value					= row.Cells[1].Text.ToString();							//1.번호
			lbl_pk.Text					= gv.DataKeys[row.RowIndex].Values["Seq"].ToString();	//2.Seq
			ddl_bnk_cd.SelectedValue	= gv.DataKeys[row.RowIndex].Values["Bnk_Cd"].ToString();//3.Bnk_Cd
			lbl_bank_nm.Text			= lbtn_rc.Text + "(" + row.Cells[6].Text.ToString() + ")";//4.은행명(소유자)
			txt_card_num.Text			= row.Cells[5].Text.ToString();							//5.보안카드번호
			txt_owner_nm.Text			= row.Cells[6].Text.ToString();							//6.소유자
			lbl_no_01.Text				= gv.DataKeys[row.RowIndex].Values["No_01"].ToString();	//7.No_01
			lbl_no_02.Text				= gv.DataKeys[row.RowIndex].Values["No_02"].ToString();	//8.No_02
			lbl_no_03.Text				= gv.DataKeys[row.RowIndex].Values["No_03"].ToString();	//9.No_03
			lbl_no_04.Text				= gv.DataKeys[row.RowIndex].Values["No_04"].ToString();	//10.No_04
			lbl_no_05.Text				= gv.DataKeys[row.RowIndex].Values["No_05"].ToString();	//11.No_05
			lbl_no_06.Text				= gv.DataKeys[row.RowIndex].Values["No_06"].ToString();	//12.No_06
			lbl_no_07.Text				= gv.DataKeys[row.RowIndex].Values["No_07"].ToString();	//13.No_07
			lbl_no_08.Text				= gv.DataKeys[row.RowIndex].Values["No_08"].ToString();	//14.No_08
			lbl_no_09.Text				= gv.DataKeys[row.RowIndex].Values["No_09"].ToString();	//15.No_09
			lbl_no_10.Text				= gv.DataKeys[row.RowIndex].Values["No_10"].ToString();	//16.No_10
			lbl_no_11.Text				= gv.DataKeys[row.RowIndex].Values["No_11"].ToString();	//17.No_11
			lbl_no_12.Text				= gv.DataKeys[row.RowIndex].Values["No_12"].ToString();	//18.No_12
			lbl_no_13.Text				= gv.DataKeys[row.RowIndex].Values["No_13"].ToString();	//19.No_13
			lbl_no_14.Text				= gv.DataKeys[row.RowIndex].Values["No_14"].ToString();	//20.No_14
			lbl_no_15.Text				= gv.DataKeys[row.RowIndex].Values["No_15"].ToString();	//21.No_15
			lbl_no_16.Text				= gv.DataKeys[row.RowIndex].Values["No_16"].ToString();	//22.No_16
			lbl_no_17.Text				= gv.DataKeys[row.RowIndex].Values["No_17"].ToString();	//23.No_17
			lbl_no_18.Text				= gv.DataKeys[row.RowIndex].Values["No_18"].ToString();	//24.No_18
			lbl_no_19.Text				= gv.DataKeys[row.RowIndex].Values["No_19"].ToString();	//25.No_19
			lbl_no_20.Text				= gv.DataKeys[row.RowIndex].Values["No_20"].ToString();	//26.No_20
			lbl_no_21.Text				= gv.DataKeys[row.RowIndex].Values["No_21"].ToString();	//27.No_21
			lbl_no_22.Text				= gv.DataKeys[row.RowIndex].Values["No_22"].ToString();	//28.No_22
			lbl_no_23.Text				= gv.DataKeys[row.RowIndex].Values["No_23"].ToString();	//29.No_23
			lbl_no_24.Text				= gv.DataKeys[row.RowIndex].Values["No_24"].ToString();	//30.No_24
			lbl_no_25.Text				= gv.DataKeys[row.RowIndex].Values["No_25"].ToString();	//31.No_25
			lbl_no_26.Text				= gv.DataKeys[row.RowIndex].Values["No_26"].ToString();	//32.No_26
			lbl_no_27.Text				= gv.DataKeys[row.RowIndex].Values["No_27"].ToString();	//33.No_27
			lbl_no_28.Text				= gv.DataKeys[row.RowIndex].Values["No_28"].ToString();	//34.No_28
			lbl_no_29.Text				= gv.DataKeys[row.RowIndex].Values["No_29"].ToString();	//35.No_29
			lbl_no_30.Text				= gv.DataKeys[row.RowIndex].Values["No_30"].ToString();	//36.No_30
			lbl_no_31.Text				= gv.DataKeys[row.RowIndex].Values["No_31"].ToString();	//37.No_31
			lbl_no_32.Text				= gv.DataKeys[row.RowIndex].Values["No_32"].ToString();	//38.No_32
			lbl_no_33.Text				= gv.DataKeys[row.RowIndex].Values["No_33"].ToString();	//39.No_33
			lbl_no_34.Text				= gv.DataKeys[row.RowIndex].Values["No_34"].ToString();	//40.No_34
			lbl_no_35.Text				= gv.DataKeys[row.RowIndex].Values["No_35"].ToString();	//41.No_35
			lbl_no_36.Text				= gv.DataKeys[row.RowIndex].Values["No_36"].ToString();	//42.No_36
			lbl_no_37.Text				= gv.DataKeys[row.RowIndex].Values["No_37"].ToString();	//43.No_37
			lbl_no_38.Text				= gv.DataKeys[row.RowIndex].Values["No_38"].ToString();	//44.No_38
			lbl_no_39.Text				= gv.DataKeys[row.RowIndex].Values["No_39"].ToString();	//45.No_39
			lbl_no_40.Text				= gv.DataKeys[row.RowIndex].Values["No_40"].ToString();	//46.No_40

			//보안번호
			using (AccessCheck access = new AccessCheck())
			{
				if (access.CheckPgmUsingGrant(USER_DIV, PID))
				{
					ClearSecuValue();
					gs_page_mode = "U";
				}
				else
				{
					CallMsgBoxInAjax("MSG_ERR_109");	//작업에 필요한 권한이 없습니다
				}
			}
		}

		#endregion

		#region 버튼이벤트

		//검색
		protected void ibtn_search_Click(object sender, EventArgs e)
		{
			SearchProcess();
		}

		//저장
		protected void ibtn_save_Click(object sender, EventArgs e)
		{
			if (global.CheckSaveMode("UPDMS_MNY_BNK_SECU_CARD", "Seq", lbl_pk.Text.Trim()))
			{
				UpdateProcess();
			}
			else
			{
				InsertProcess();
			}
		}

		//삭제
		protected void ibtn_delete_Click(object sender, EventArgs e)
		{
			StringBuilder sb = new StringBuilder();

			sb.Append("<UPDMS>");

			for (int i = 0; i < GridView1.Rows.Count; i++)
			{
				GridViewRow row = GridView1.Rows[i];
				HtmlInputCheckBox cb = (HtmlInputCheckBox)row.FindControl("cb_check");

				if (cb.Checked)
				{
					string ls_seq = GridView1.DataKeys[i].Values["Seq"].ToString();
					sb.Append("<UPDMS_MNY_BNK_SECU_CARD>");
					sb.Append("<Seq>" + ls_seq + "</Seq>");
					sb.Append("</UPDMS_MNY_BNK_SECU_CARD>");
				}
			}
			sb.Append("</UPDMS>");

			DeleteProcess(sb.ToString());
		}

		//보안번호검색
		protected void ibtn_secu_search_Click(object sender, EventArgs e)
		{
			using (AccessCheck access = new AccessCheck())
			{
				if (access.IsAdministrator(USER_ID, txt_secu_admin_pw.Text.Trim()))
				{
					SearchSecuProcess();
				}
				else
				{
					CallMsgBoxInAjax("MSG_ERR_129");	//관리자 비밀번호가 아닙니다
				}
			}
		}

		//모두보기
		protected void cb_list_all_CheckedChanged(object sender, EventArgs e)
		{
			SearchProcess();
		}

		#endregion

	}
}
